<template>
	<view class="page bg-white">
		<!-- 标题栏 start -->
		<fu-custom bgColor="bg-white" :isBack="true" :isBottom="true">
			<block slot="content">{{pagetype=='sign'?i18n['签到规则']:i18n['积分规则']}}</block>
		</fu-custom>
		<!-- 标题栏 end -->
		<!-- 页面loading start -->
		<fu-loading v-if="isShowLoading"></fu-loading>
		<!-- 页面loading end -->
		<!-- 积分内容 start -->
		<view class="padding" v-else>
			<!-- <view v-html="text"></view> -->
			<jyf-parser :html="text || '暂无相关内容'"></jyf-parser>
		</view>
		<!-- 积分内容 end -->
	</view>
</template>
<script>
	import richText from '@/common/utils/richText.js';
	export default {
		data() {
			return {
				isShowLoading: false, //是否显示加载loading
				text: '', //规则内容
				pagetype: '' //sign 获取签到规则
			};
		},
		onLoad(e) {
			this.pagetype = e.pagetype
			if (e.pagetype == 'sign') {
				this.getRule()
			} else {
				this.getData();
			}
		},
		methods: {
			/**
			 * @description 获取签到规则
			 */
			getRule() {
				this.$api
					.post(global.apiUrls.postUserSigninRule, {
						category_id: 13
					})
					.then(res => {
						if (res.data.code == 1) {
							this.text = res.data.data.content;
						} else {
							// this.$message.info(res.data.msg);
						}
					})
					.catch(err => {
						console.log(err, '>>>>>>>>>>>>>>>');
					});
			},
			/**
			 * @description 获取积分规则数据
			 */
			getData() {
				this.isShowLoading = true;
				this.$api
					.post(global.apiUrls.postOperationGetColumn, {
						category_id: 6
					})
					.then(res => {
						this.isShowLoading = false;
						if (res.data.code == 1) {
							this.text = res.data.data.content;
						} else {
							this.$message.info(res.data.msg);
						}
					})
					.catch(err => {
						this.isShowLoading = false;
						console.log('err: ' + JSON.stringify(err));
					});
			}
		}
	};
</script>

<style lang="scss" scoped>
	// 规则内容 start
	.page {
		min-width: 100%;
	}

	.padding {
		height: 100vh;
	}

	// 规则内容 end
</style>
